package biz

import (
	"git.bybit.com/svc/go/pkg/bconst"
	"git.bybit.com/svc/mod/pkg/bproto"
	"git.bybit.com/svc/stub/pkg/svc/common"
)

type serverError string
type paramError string
type failError string

const (
	// internal
	ErrorBadParams paramError  = "DT2001"
	ErrorNoData    serverError = "DT2002"
	ErrorFAIL      failError   = ""
)

var (
	ErrWaitForLoading = bproto.NewError(bconst.RpcErrorCodeBusy, "ErrWaitForLoading")
)

func (se serverError) Error() string {
	return string(se)
}

func (se serverError) CommonError(debugMessage string) *common.Error {
	return bproto.NewErrorWithMessage(bconst.RpcErrorCodeInternal, string(se), debugMessage)
}

func (pe paramError) Error() string {
	return string(pe)
}

func (pe paramError) CommonError(debugMessage string) *common.Error {
	return bproto.NewErrorWithMessage(bconst.RpcErrorCodeBadParam, string(pe), debugMessage)
}

func (fe failError) Error() string {
	return string(fe)
}

func (fe failError) CommonError(debugMessage string) *common.Error {
	bpErr := bproto.NewErrorWithMessage(bconst.RpcErrorCodeFailed, string(fe), debugMessage)

	return bpErr
}
